package cn.chenchendemospringboot.order_demo.controller;

import cn.chenchendemospringboot.order_demo.entity.KafkaEventPublish;
import cn.chenchendemospringboot.order_demo.utils.KafkaUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("/kafkaTest")
public class KafkaTest {
    @GetMapping("/test")
    public String kafkaTest() {
        // 调用Service层的saveOrder方法
        for(int i = 11;i<=20;i++){
            try {
                KafkaUtils.sendSync("cctest1","这是测试的第" + i + "条消息");
            } catch (ExecutionException e) {
                throw new RuntimeException(e);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        return "1";
    }
}
